<?php
namespace backend\models;

use Yii;
use yii\base\Model;
use yii\base\Exception;
use common\models\CustomerOrder;
use common\models\OrderProduct;
use common\models\TransferUndertake;
use common\models\User;

class TaskForm extends Model
{
	public $username;
	public $sex;
	public $mobileNumber;
	public $birthday;
	public $pid;

	public function formName()
    {
        return '';
    }

	public function rules()
	{
		return [
			[['username', 'sex', 'mobileNumber', 'birthday'], 'safe']
		];
	}

	public function query()
	{
		$employee = User::findOne(Yii::$app->user->id)->employee;
		$data = TransferUndertake::find()->where(['undertake' => $employee->id, 'status' => TransferUndertake::ACTIVE_STATUS]);
		// if ($this->username) {
		// 	$data = $data->andWhere(['like', 'customer.username', $this->username]);
		// }
		// if ($this->sex) {
		// 	$data = $data->andWhere(['customer.sex' => $this->sex]);
		// }
		// if ($this->mobileNumber) {
		// 	$data = $data->andWhere(['customer.mobileNumber' => $this->mobileNumber]);
		// }
		// if ($this->birthday) {
		// 	$re = explode('-', $this->birthday);
		// 	$begin = strtotime(trim($re[0]));
		// 	$end = strtotime(trim($re[1]));
		// 	$data = $data->andWhere('customer.birthday >= ' . $begin)->andWhere('customer.birthday <= ' . $end);
		// }
		// if ($this->pid) {
		// 	$data = $data->joinWith('intention')->where(['customer_intention.pid' => $this->pid]);
		// }

		return $data;
	}

}	